<?php
namespace Academico\Model;

use Zend\Db\Sql\Sql;
use Zend\Db\Sql\Where;
use Zend\Db\ResultSet\ResultSet;
use \OcaBase\Db\TableGateway\TableGateway;

class Aula extends TableGateway
{
    protected $schemaName = 'frequencia';
    protected $tableName  = 'aula';

    /**
     * Pega as aulas por turma
     * @param integer $idTurma
     * @return ResultSet
     */
    public function pegarPorTurma($idTurma)
    {
        $sql    = new Sql($this->getAdapter());
        $select = $sql->select();
        $select->from($this->table);

        $where = new Where();
        //$where->equalTo('id_aula', $idTurma);

        $select->where($where)
               ->order('dt_aula ASC');
        //print_r($sql->getSqlStringForSqlObject($select));die;

        $statement = $sql->prepareStatementForSqlObject($select);
        $results   = $statement->execute();

        $resultSet = new ResultSet();
        $resultSet->initialize($results);
        return $resultSet;
    }
}
